import React from 'react'
import { Table,Button } from 'antd';
import withRouter from "umi/withRouter"

function StudentTable(props) {
    const columns = [
        {
            title: '学号',
            dataIndex: 'sNo'
        },
        {
            title: '姓名',
            dataIndex: 'name'
        },
        {
            title: '性别',
            dataIndex: 'sex',
            render(sex) {
                return sex === 1 ? "女" : "男"
            }
        },
        {
            title: '出生年份',
            dataIndex: 'birth'
        },
        {
            title: '性邮箱别',
            dataIndex: 'email'
        },
        {
            title: '修改',
            render(stu) {
                return <Button type="link" onClick={() => {
                    props.history.push(`/student/${stu.sNo}`)
                }}>详情</Button>
            }
        }
    ];
    return (
        <Table columns={columns} rowKey="id" dataSource={props.stus} 
            pagination={{
                current: props.current,
                total: props.total,
                panelNumber: 5,
                showQuickJumper: true,
                onChange: props.onChange
            }}
            loading={props.loading}
            style={{
                marginTop:"20px"
            }}
        />
    )
}


export default withRouter(StudentTable)